package camid.distribution.lifecycle.perclient;

public class Lease {

	private long leaseValue;
	private long initial;
	
	public Lease(long leaseValue) 
	{
		this.leaseValue = leaseValue;
		initial = System.currentTimeMillis();
	}

	public void renew()
	{
		long current = System.currentTimeMillis();
		if(current - initial <= leaseValue)
		{
			initial = current;
		}
	}
	
	public boolean isValid()
	{
		long current = System.currentTimeMillis();
		return (current - initial <= leaseValue); 
	}
	
}
